package com.tfswue.cxy.service;


import com.tfswue.cxy.apis.UserClinet;
import com.tfswue.cxy.entity.Order;
import com.tfswue.cxy.entity.User;
import com.tfswue.cxy.mapper.OrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Service
public class OrderService {
    @Autowired
    private OrderMapper orderMapper;
    @Autowired
    private RestTemplate restTemplate;
    @Autowired
    private UserClinet userClinet;

    public Order getOrderById(Long id){
        Order order = (Order) orderMapper.selectById(id);
        User user = userClinet.getUserById(order.getUserId());
        order.setUser(user);
//       userClinet.getUserById(order.getUserId());
//        order.setUser((org.apache.catalina.User) restTemplate.getForObject
//                ("http://user_server/api/users/" + order.getUserId(), User.class));
        return order;
    }
}
